package com.basker.pisces.core.datasource;

import org.springframework.util.Assert;

public enum DbType {

    /**
     * Mysql数据库
     */
    MySQL("MySql", "MySql"),

    /**
     * SqlServer数据库
     */
    SqlServer("SqlServer", "Microsoft SQL Server");

    public static DbType fromDatabaseProductName(String productName) {
        Assert.hasText(productName, "parameter 'productName' is required");

        for (DbType dbType : values()) {
            if (productName.equalsIgnoreCase(dbType.productName)) {
                return dbType;
            }
        }

        throw new RuntimeException("productName:" + productName + " is not support");
    }

    private final String productName;

    private final String alias;

    DbType(String alias, String productName) {
        this.alias = alias;
        this.productName = productName;
    }

    public String getAlias() {
        return alias;
    }

}
